This specification relates to query planning for distributed databases.
Massive distributed databases include tables that are partitioned across multiple storage devices, in which each partition stores a subset of the rows or columns of a particular table.
Some database systems can compute a result for queries that include common table expressions (CTEs). A CTE is an expression in a query that has a name and one or more associated definitional statements. A database system can compute a result for the one or more associated statements and materialize the result in memory or in an underlying storage subsystem. When the query references the name of the CTE, a database system can read the materialized result from memory or storage rather than recomputing the result for the statements associated with the CTE.